<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
	<TITLE></TITLE>
	<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2  (Unix)">
	<META NAME="CREATED" CONTENT="0;0">
	<META NAME="CHANGED" CONTENT="20101228;15443900">
	<STYLE TYPE="text/css">
	<!--
		@page { margin: 0.79in }
		P { margin-bottom: 0.08in }
		PRE { font-family: "Times New Roman" }
	-->
	</STYLE>
</HEAD>
<BODY LANG="el-GR" DIR="LTR">
<PRE LANG="en-US"><FONT SIZE=5><B>lininger2vs</B></FONT>

<FONT SIZE=4><SPAN LANG="en-US">Solves an initial value problem, given as an autonomous system of second (or possibly third) order ordinary differential equations by means of an implicit, first-order accurate, exponentially fitted one-step method.</SPAN></FONT>

<FONT SIZE=4><SPAN LANG="en-US"><B>Example: Can be run with F5 within the ScalaLab Editor (Ctrl-E to open the editor)</B></SPAN></FONT>


<FONT SIZE=3><SPAN LANG="en-US">import java.text.DecimalFormat;</SPAN></FONT>
<FONT SIZE=3><SPAN LANG="en-US">import numal.*;</SPAN></FONT>

<FONT SIZE=3><SPAN LANG="en-US">public class Test_liniger2_1 extends Object</SPAN></FONT>
                             <FONT SIZE=3><SPAN LANG="en-US">implements AP_liniger2_methods {</SPAN></FONT>

  <FONT SIZE=3><SPAN LANG="en-US">static int passes,pasjac;</SPAN></FONT>
   
<FONT SIZE=3><SPAN LANG="en-US">	public static void main(String args[]) {</SPAN></FONT>

    <FONT SIZE=3><SPAN LANG="en-US">int i,itmax;</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">int k[] = new int[1];</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">double step;</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">double y[] = new double[3];</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">double j[][] = new double[3][3];</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">double x[] = new double[1];</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">double sigma1[] = new double[1];</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">double sigma2[] = new double[1];</SPAN></FONT>
    
    <FONT SIZE=3><SPAN LANG="en-US">Test_liniger2_1 testliniger2 = new Test_liniger2_1();</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">System.out.println(&quot;The results with LINIGER2 (second order)&quot; +</SPAN></FONT>
      <FONT SIZE=3><SPAN LANG="en-US">&quot; are:\n K    DER.EV.  JAC.EV.     Y[1]            Y[2]&quot;);</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">for (i=1; i&lt;=2; i++) {</SPAN></FONT>
      <FONT SIZE=3><SPAN LANG="en-US">step = (i == 1) ? 10.0 : 1.0;</SPAN></FONT>
      <FONT SIZE=3><SPAN LANG="en-US">for (itmax=1; itmax&lt;=3; itmax += 2) {</SPAN></FONT>
        <FONT SIZE=3><SPAN LANG="en-US">passes=pasjac=0;</SPAN></FONT>
        <FONT SIZE=3><SPAN LANG="en-US">x[0]=y[2]=0.0;</SPAN></FONT>
        <FONT SIZE=3><SPAN LANG="en-US">y[1]=1.0;</SPAN></FONT>
        <FONT SIZE=3><SPAN LANG="en-US">sigma2[0]=0.0;</SPAN></FONT>
        <FONT SIZE=3><SPAN LANG="en-US">Analytic_problems.liniger2(x,50.0,2,y,sigma1,sigma2,</SPAN></FONT>
                 <FONT SIZE=3><SPAN LANG="en-US">testliniger2,j,k,itmax,step,1.0e-4,1.0e-4);</SPAN></FONT>
      <FONT SIZE=3><SPAN LANG="en-US">}</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">}</SPAN></FONT>
<FONT SIZE=3><SPAN LANG="en-US">	}</SPAN></FONT>


  <FONT SIZE=3><SPAN LANG="en-US">public double f(int m, double y[], int i, double sigma1[],</SPAN></FONT>
                  <FONT SIZE=3><SPAN LANG="en-US">double sigma2[])</SPAN></FONT>
  <FONT SIZE=3><SPAN LANG="en-US">{</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">if (i == 1)</SPAN></FONT>
      <FONT SIZE=3><SPAN LANG="en-US">return (y[1]+0.99)*(y[2]-1.0)+0.99;</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">else {</SPAN></FONT>
      <FONT SIZE=3><SPAN LANG="en-US">passes++;</SPAN></FONT>
      <FONT SIZE=3><SPAN LANG="en-US">return 1000.0*((1.0+y[1])*(1.0-y[2])-1.0);</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">}</SPAN></FONT>
  <FONT SIZE=3><SPAN LANG="en-US">}</SPAN></FONT>


  <FONT SIZE=3><SPAN LANG="en-US">public void jacobian(int m, double j[][], double y[],</SPAN></FONT>
                       <FONT SIZE=3><SPAN LANG="en-US">double sigma1[], double sigma2[])</SPAN></FONT>
  <FONT SIZE=3><SPAN LANG="en-US">{</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">j[1][1]=y[2]-1.0;</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">j[1][2]=0.99+y[1];</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">j[2][1]=1000.0*(1.0-y[2]);</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">j[2][2] = -1000.0*(1.0+y[1]);</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">sigma1[0]=Math.abs(j[2][2]+j[1][1]-</SPAN></FONT>
              <FONT SIZE=3><SPAN LANG="en-US">Math.sqrt((j[2][2]-j[1][1])*</SPAN></FONT>
              <FONT SIZE=3><SPAN LANG="en-US">(j[2][2]-j[1][1])+4.0*j[2][1]*j[1][2]))/2.0;</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">pasjac++;</SPAN></FONT>
  <FONT SIZE=3><SPAN LANG="en-US">}</SPAN></FONT>


  <FONT SIZE=3><SPAN LANG="en-US">public boolean evaluate(int i)</SPAN></FONT>
  <FONT SIZE=3><SPAN LANG="en-US">{</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">return (i == 1);</SPAN></FONT>
  <FONT SIZE=3><SPAN LANG="en-US">}</SPAN></FONT>


  <FONT SIZE=3><SPAN LANG="en-US">public void output(double x[], double xe, int m,</SPAN></FONT>
                     <FONT SIZE=3><SPAN LANG="en-US">double y[],double sigma1[],</SPAN></FONT>
                     <FONT SIZE=3><SPAN LANG="en-US">double sigma2[], double j[][], int k[])</SPAN></FONT>
  <FONT SIZE=3><SPAN LANG="en-US">{</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">DecimalFormat fiveDigit = new DecimalFormat(&quot;0.00000E0&quot;);</SPAN></FONT>
    <FONT SIZE=3><SPAN LANG="en-US">if (x[0] == 50.0)</SPAN></FONT>
      <FONT SIZE=3><SPAN LANG="en-US">System.out.println(&quot; &quot; +</SPAN></FONT>
        <FONT SIZE=3><SPAN LANG="en-US">k[0] + &quot;\t&quot; + passes + &quot;\t&quot; + pasjac + &quot;\t&quot; +</SPAN></FONT>
        <FONT SIZE=3><SPAN LANG="en-US">fiveDigit.format(y[1]) + &quot;\t&quot; + </SPAN></FONT>
        <FONT SIZE=3><SPAN LANG="en-US">fiveDigit.format(y[2]));</SPAN></FONT>
  <FONT SIZE=3><SPAN LANG="en-US">}</SPAN></FONT>
<FONT SIZE=3><SPAN LANG="en-US">}</SPAN></FONT></PRE>
</BODY>
</HTML>